<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>演示mounted</title>
    <script src="../../js/vue/vue.js"></script>
    <script src="../../js/vue/jquery.js"></script>
</head>
<body>
<div id="app">
    <ul>
        <!-- index:显示索引 -->
        <li v-for="(u,index) in users">{{u.name}}-{{u.age}}-{{index}}</li>
    </ul>
</div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            users: []
        },
        mounted: function () {
            // mounted是一个函数,html模板加载完毕,vue准备渲染数据时调用
            //一般用于初始化data中的数据
            $.get('/js/vue/user.json', {}, function (data) {
                // 将获取到的jsons格式数据赋值给vue事例中的users
                app.users = data;
            })
        }
    })
</script>
</body>
</html>